<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace="FReceipt" xmlns="http://ibatis.apache.org/mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<alias>
    <typeAlias alias="FReceipt" type="EIA.PM.Model.FReceipt, EIA.PM.Model" />
</alias>

<resultMaps>
<resultMap id="select-freceipt-result" class="FReceipt">
<constructor>
    <argument argumentName="receipt_id" column="receipt_id"/>
    <argument argumentName="prj_id" column="prj_id"/>
    <argument argumentName="invoice_no" column="invoice_no"/>
    <argument argumentName="receipt_way" column="receipt_way"/>
    <argument argumentName="receipt_date" column="receipt_date"/>
    <argument argumentName="receipt_amount" column="receipt_amount"/>
    <argument argumentName="_date" column="_date"/>
    <argument argumentName="_staff" column="_staff"/>
</constructor>
<!--
    <result property="ReceiptId" column="receipt_id"/>
    <result property="PrjId" column="prj_id"/>
    <result property="InvoiceNo" column="invoice_no"/>
    <result property="ReceiptWay" column="receipt_way"/>
    <result property="ReceiptDate" column="receipt_date"/>
    <result property="ReceiptAmount" column="receipt_amount"/>
    <result property="Date" column="_date"/>
    <result property="Staff" column="_staff"/>
-->
</resultMap>
</resultMaps>

<statements>
<sql id="sql_FReceipt_where_pk">
WHERE receipt_id=#ReceiptId#
</sql>

<sql id="sql_FReceipt_where_cv">
<dynamic prepend="WHERE">
    <isPropertyAvailable property="ReceiptId" prepend="AND">receipt_id=#ReceiptId#</isPropertyAvailable>
    <isPropertyAvailable property="PrjId" prepend="AND">prj_id=#PrjId#</isPropertyAvailable>
    <isPropertyAvailable property="InvoiceNo" prepend="AND">invoice_no LIKE concat('%', #InvoiceNo#, '%')</isPropertyAvailable>
    <isPropertyAvailable property="ReceiptWay" prepend="AND">receipt_way=#ReceiptWay#</isPropertyAvailable>
    <isPropertyAvailable property="ReceiptDate" prepend="AND">receipt_date=#ReceiptDate#</isPropertyAvailable>
    <isPropertyAvailable property="ReceiptAmount" prepend="AND">receipt_amount=#ReceiptAmount#</isPropertyAvailable>
    <isPropertyAvailable property="Date" prepend="AND">_date=#Date#</isPropertyAvailable>
    <isPropertyAvailable property="Staff" prepend="AND">_staff=#Staff#</isPropertyAvailable>
</dynamic>
</sql>

<sql id="sql_FReceipt_set_cols">
<dynamic prepend="SET">
    <isPropertyAvailable property="PrjId" prepend=",">prj_id=#PrjId#</isPropertyAvailable>
    <isPropertyAvailable property="InvoiceNo" prepend=",">invoice_no=#InvoiceNo#</isPropertyAvailable>
    <isPropertyAvailable property="ReceiptWay" prepend=",">receipt_way=#ReceiptWay#</isPropertyAvailable>
    <isPropertyAvailable property="ReceiptDate" prepend=",">receipt_date=#ReceiptDate#</isPropertyAvailable>
    <isPropertyAvailable property="ReceiptAmount" prepend=",">receipt_amount=#ReceiptAmount#</isPropertyAvailable>
    <isPropertyAvailable property="Date" prepend=",">_date=#Date#</isPropertyAvailable>
    <isPropertyAvailable property="Staff" prepend=",">_staff=#Staff#</isPropertyAvailable>
</dynamic>
</sql>

<select id="SelectFReceipt" parameterClass="" resultMap="FReceipt.select-freceipt-result">
SELECT *
FROM f_receipt
<include refid="sql_FReceipt_where_pk"/><!--where-->
</select>

<select id="SelectFReceipt_CV" parameterClass="System.Collections.IDictionary" resultMap="FReceipt.select-freceipt-result">
SELECT *
FROM f_receipt
<include refid="sql_FReceipt_where_cv"/><!--where-->
</select>

<insert id="InsertFReceipt" parameterClass="FReceipt">
<!--pre selectKey place-->
INSERT INTO f_receipt(
<dynamic prepend=" ">
    <isPropertyAvailable property="PrjId" prepend=",">prj_id</isPropertyAvailable>
    <isPropertyAvailable property="InvoiceNo" prepend=",">invoice_no</isPropertyAvailable>
    <isPropertyAvailable property="ReceiptWay" prepend=",">receipt_way</isPropertyAvailable>
    <isPropertyAvailable property="ReceiptDate" prepend=",">receipt_date</isPropertyAvailable>
    <isPropertyAvailable property="ReceiptAmount" prepend=",">receipt_amount</isPropertyAvailable>
    <isPropertyAvailable property="Date" prepend=",">_date</isPropertyAvailable>
    <isPropertyAvailable property="Staff" prepend=",">_staff</isPropertyAvailable>
</dynamic>
)VALUES(
<dynamic prepend=" ">
    <isPropertyAvailable property="PrjId" prepend=",">#PrjId#</isPropertyAvailable>
    <isPropertyAvailable property="InvoiceNo" prepend=",">#InvoiceNo#</isPropertyAvailable>
    <isPropertyAvailable property="ReceiptWay" prepend=",">#ReceiptWay#</isPropertyAvailable>
    <isPropertyAvailable property="ReceiptDate" prepend=",">#ReceiptDate#</isPropertyAvailable>
    <isPropertyAvailable property="ReceiptAmount" prepend=",">#ReceiptAmount#</isPropertyAvailable>
    <isPropertyAvailable property="Date" prepend=",">#Date#</isPropertyAvailable>
    <isPropertyAvailable property="Staff" prepend=",">#Staff#</isPropertyAvailable>
</dynamic>
)
<selectKey resultClass="int" type="post" property="ReceiptId" >
SELECT LAST_INSERT_ID()
</selectKey>
</insert>

<update id="UpdateFReceipt" parameterClass="System.Collections.IDictionary">
UPDATE f_receipt
<include refid="sql_FReceipt_set_cols"/><!--set-->
<include refid="sql_FReceipt_where_pk"/><!--where-->
</update>

<delete id="DeleteFReceipt" parameterClass="">
DELETE FROM f_receipt
<include refid="sql_FReceipt_where_pk"/><!--where-->
</delete>

<statement id="DeleteFReceipt_CV" parameterClass="FReceipt">
DELETE FROM f_receipt
<include refid="sql_FReceipt_where_cv"/><!--where-->
</statement>

<delete id="ClearFReceipt">
DELETE FROM f_receipt
</delete>
</statements>
</sqlMap>